<?php

declare(strict_types=1);

namespace App\Model;


/**
 * @property int $id ID
 * @property string $match_id ID
 * @property string $game_id 赛事ID
 * @property int $sport_id 运动类型
 * @property string $game_name 赛事名称
 * @property string $game_logo 赛事LOGO
 * @property string $home_team_id 主队ID
 * @property string $home_team_name 主队名称
 * @property string $home_team_logo 主队LOGO
 * @property string $home_team_scores 主队得分
 * @property string $home_double_teams 主队双打队伍
 * @property string $away_team_id 客队ID
 * @property string $away_team_name 客队名称
 * @property string $away_team_logo 客队LOGO
 * @property string $away_team_scores 客队得分
 * @property string $away_double_teams 客队双打队伍
 * @property string $vb_scores 排球比分
 * @property int $match_time 比赛时间
 * @property int $match_date 比赛日期
 * @property int $match_status 比赛状态 1-待开赛 2-正在比赛 3-已结束
 * @property int $sp_match_status spMatchStatus
 * @property int $match_end_time 比赛结束时间
 * @property int $match_progress 比赛进度
 * @property int $match_status_id 比赛子状态
 * @property string $video_url 比赛原始视频直播地址
 * @property string $animate_url 比赛动画地址
 * @property string $times 倒计时
 * @property string $tennis_scores 网球积分
 * @property int $tennis_double_flag 双打
 * @property string $tennis_game_points 网球点
 * @property int $tennis_serve 网球发球方
 * @property int $sync_time 同步时间
 * @property-read null|PlayDatum $data 
 * @property-read null|\Hyperf\Database\Model\Collection|Live[] $live 
 * @property-read null|\Hyperf\Database\Model\Collection|Project[] $project 
 */
class Play extends Model
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'play';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'match_id', 'game_id', 'sport_id', 'game_name', 'game_logo', 'home_team_id', 'home_team_name', 'home_team_logo', 'home_team_scores', 'home_double_teams', 'away_team_id', 'away_team_name', 'away_team_logo', 'away_team_scores', 'away_double_teams', 'vb_scores', 'match_time', 'match_date', 'match_status', 'sp_match_status', 'match_end_time', 'match_progress', 'match_status_id', 'video_url', 'animate_url', 'times', 'tennis_scores', 'tennis_double_flag', 'tennis_game_points', 'tennis_serve', 'sync_time'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'sport_id' => 'integer', 'match_time' => 'integer', 'match_date' => 'integer', 'match_status' => 'integer', 'sp_match_status' => 'integer', 'match_end_time' => 'integer', 'match_progress' => 'integer', 'match_status_id' => 'integer', 'tennis_double_flag' => 'integer', 'tennis_serve' => 'integer', 'sync_time' => 'integer'];

    public function data(){
        return $this->hasOne(PlayDatum::class, 'match_id', 'match_id');
    }

    public function live(){
        return $this->hasMany(Live::class, 'match_id', 'match_id');
    }

    public function project(){
        return $this->hasMany(Project::class, 'match_id', 'match_id');
    }
}
